from sqlalchemy import String
from sqlalchemy.orm import Mapped, mapped_column

from app.database.db import uuid4_str
from app.models.base import Base, id_key


class User(Base):
    id: Mapped[id_key] = mapped_column(init=False)
    uuid: Mapped[str] = mapped_column(
        String(50), init=False, default_factory=uuid4_str, unique=True
    )
    username: Mapped[str] = mapped_column(index=True, unique=True, comment="用户名")
    name: Mapped[str] = mapped_column(index=True)
    password: Mapped[str]
    salt: Mapped[str | None] = mapped_column(String(5), comment="加密盐")
